<template>
  <div id="app" class="theme">
    <div id="nav">
      <router-link to="/">Home</router-link>|
      <router-link to="/about">About</router-link>|
      <router-link to="/button">Button</router-link>|
      <router-link to="/tabbar">Tabbar</router-link>
    </div>
    <div>
      <button @click="changeTheme">切换主题</button>
    </div>
    <router-view />
  </div>
</template>
<script>
export default {
  data() {
    return {
      theme: false
    };
  },
  watch:{
    theme(newVal){
      let app = document.getElementById("app");
      if(newVal){
        app.className = "theme--blue";
      }else{
         app.className = "theme";
      }
    }
  },
  created() {},
  mounted() {
  },
  methods: {
    changeTheme() {
      this.theme = !this.theme;
    }
  }
};
</script>

<style lang="less">
.theme(@color:@red) {
  #nav {
    padding: 30px;
    font-family: Avenir, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-align: center;
    color: #2c3e50;
    font-size: 20px;
    a {
      font-weight: bold;
      color: @color;

      &.router-link-exact-active {
        color: #42b983;
      }
    }
  }
}
.theme {
  .theme();
  &--blue {
    .theme(@blue);
  }
}
</style>
